#include "app.h"
#include "app_task.h"

#include "um_pt.h"
#include "um_tim.h"

#include "uart.h"


AB_Loop_t  ab_loop;

void TIM2_IRQHandler(void)
{//1ms
    TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
    UM_Systick_Handler();
}

s32  GetTickCount()
{
	return (s32)UM_SYS_TIMER.systicks;
}

void App()
{
	UM_TimInit(TIM2,3600, 20,1);

    firber_laser.type = 5;

	Data_Init();

    pt_thread_init();
    pt_thread_add(&pt_thread_driver,&thread_driver);
    pt_thread_add(&pt_thread_usmart,&thread_usmart);
    pt_thread_add(&pt_thread_state,&thread_state);


    pt_thread_add(&pt_thread_pad,&thread_pad);
}


void setup(void)
{
	__disable_irq();
    //SystemInit(); // system initialization , system clock set as 72Mhz.
//	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
    UM_NVIC_PriorityGroupConfig();

	BSP_Init();

    App();
    __enable_irq();
}

void loop(void)
{
	pt_thread_scheduler();
}
